﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="Hoiatused", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(Hoiatused))]
    public class HoiatusedSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IHoiatused clazz;
        
        public HoiatusedSerializer(IHoiatused clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            for (int x = 0; ((clazz.Hoiatus != null) 
                        && (x < clazz.Hoiatus.Count)); x = (x + 1)) {
                if (clazz.Hoiatus[x]!=null) {
                    Writer.WriteStartElement("hoiatus");
                    Writer.WriteTypeAttribute("http://producers.etoimik.xtee.riik.ee/producer/etoimik", ">>Hoiatused>hoiatus");
                    Writer.WriteString(clazz.Hoiatus[x].ToString());
                    Writer.WriteEndElement();
                }
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="hoiatus") {
                clazz.Hoiatus = new System.Collections.Generic.List<Hoiatused.HoiatusType>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "hoiatus")); ) {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>Hoiatused>hoiatus");
                    }
                    clazz.Hoiatus.Add(new Hoiatused.HoiatusType(Reader.ReadElementString("hoiatus")));
                }
            }
        }
    }
}
